@extends('admin.layout.layout')
@section('title','用户管理')

@section('con')
   
	<div class="admin">
  
    
    <div class="row">
            <h1 >用户列表</h1>
    </div>

    <form action="{{url('/admin/user/index')}}">
    <div class="dataTables_filter" id="DataTables_Table_0_filter">
      <label><input type="text" name="keywords" value="{{$list['keywords'] or ''}}" aria-controls="DataTables_Table_0"><button class="btn btn-info">搜索</button></label>
      
    </div>
    </form>
    <div class="widget-box">
          <div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>
            <h5>Data table</h5>

          </div>
          <div class="widget-content nopadding">
            <div role="grid" class="dataTables_wrapper" id="DataTables_Table_0_wrapper">
            <table class="table table-bordered data-table dataTable" id="DataTables_Table_0">
              <thead>
                <tr role="row" >
                    <th class="ui-state-default" style="font-size:15px;">用户编号</th>
                    <th class="ui-state-default" style="font-size:15px;">用户名</th>
                    <th class="ui-state-default" style="font-size:15px;">头像</th>
                    <th class="ui-state-default" style="font-size:15px;">手机</th>
                    <th class="ui-state-default" style="font-size:15px;">权限</th>
                    <th class="ui-state-default" style="font-size:15px;">操作</th>
                 
                  
                </tr>
              </thead>
              
            @foreach($users as $k=>$v)
            <tr >

                  <td class="  sorting_1">{{$v->id}}</td>
                  <td class=" ">{{$v->username}}</td>
                  <td ><img src="{{$v->pic}}" width="50px"></td>
                  <td class="center ">{{$v->phone}}</td>
                  <td class="center ">{{$v->auth}}</td>

                  <td style="width:120px">
                   <a href="/admin/user/edit?id={{$v->id}}" class="btn btn-warning">修改</a>
                   <button class="btn btn-danger delete-btn">删除</button>
                    <br>
                    <br>
                  <a class='btn btn-success' href="/admin/user/up?id={{$v->id}}">提权</a>
                  <a class='btn btn-success' href="/admin/user/down?id={{$v->id}}">降权</a>
            
                 
                       
                  </td>

                </tr>
            @endforeach
            </table>
          </div>

        </div>
        <style type="text/css">
              .pagination{
                list-style:none;
                color: #aaaaaa !important;
                border-radius: 4px 0 0 4px;
            
              }
              .pagination li{
                float: left;width:30px;
                 
              }
             .pagination li.active {
                    background: none repeat scroll 0 0 #41bedd !important;
                    color: #ffffff !important;
                    cursor: default !important;
                    font-size: 15px;
                }
             .pagination li a{
              background: none repeat scroll 0 0 #f5f5f5;
                  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
                  border-style: solid;
                  border-width: 1px;
                  color:#333 ;
                  display: inline-block;
                  font-size: 15px;
                  line-height: 15px;
                  padding: 4px 10px !important;
                  text-shadow: 0 1px 0 #ffffff;
             }
              </style>

        
        {!! $users->appends($list)->render() !!} 
        
@endsection
@section('js')

     <script type="text/javascript">
     $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
      });
     //绑定单击事件
     $('.delete-btn').click(function(){
      var id = $(this).parents('tr').find('.sorting_1').html();
      var btn = $(this);
    
     //发送ajax请求
     $.post('/admin/user/delete',{id:id},function(data){
      if(data == 1){
        //删除成功
        alert('删除成功');
        btn.parents('tr').remove();
      }else{
        // 删除失败
        alert('删除失败');
      }
        })
    })
     </script>   

@endsection